package com.smartlifev30.baiwei.view;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

import com.smartlifev30.R;

/**
 * 主界面viewpager, 放弃banner位置的相关事件, 不要影响banner的点击,滑动
 *
 * @author tys
 * @date 2018/8/16
 */

public class MainActivityViewPager extends ViewPager {
    private float bannerHeight;

    public MainActivityViewPager(@NonNull Context context) {
        this(context, null);
    }

    public MainActivityViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init();
    }


    private void init() {
        bannerHeight = getResources().getDimension(R.dimen.banner_height);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        return !(event.getY() <= bannerHeight) && super.onInterceptTouchEvent(event);
    }
}
